package com.lbn.jfqsc.app.recruitment.item;

import com.lbn.baseframe.mvp.BasePresenter;
import com.lbn.baseframe.net.business.RxSubscribe;
import com.lbn.jfqsc.business.bean.JobList;
import com.lbn.jfqsc.net.Host;

import java.util.List;

/**
 * Created by 李炳南
 * 2017/2/28.
 */

public class ItemPresenter extends BasePresenter<ItemView> {

    public void applyList(final int page, final int type) {

        subscribeNetwork(Host.getApi().applyList(page, type), new RxSubscribe<List<JobList>>() {
            @Override
            public void next(List<JobList> o) {
                if (page == 1) {
                    getView().setData(o);
                } else {
                    getView().addData(o);
                }

                if (o.size() < 10) {
                    getView().isMore(true);
                } else {
                    getView().isMore(false);
                }
            }
            @Override
            public void error(Throwable e) {
                getView().onError(e.getMessage());
            }
        });


    }
}
